@mixin merge-style($sideBarWidth) {
  $menuActiveText: #7a80b4;

  @media screen and (width >= 150px) and (width <= 420px) {
    .app-main-nofixed-header {
      overflow-y: hidden;
    }
  }

  @media screen and (width >= 420px) {
    .app-main-nofixed-header {
      overflow: hidden;
    }
  }

  /* 修复 windows 下双滚动条问题 */
  .el-popper.custom-menu {
    overflow: hidden;
  }

  /* popper menu 超出内容区可滚动 */
  .custom-menu {
    max-height: calc(100vh - calc(50px * 2.5));
    overflow: hidden auto;
  }

  .sub-menu-icon {
    margin-right: 5px;
    font-size: 18px;
    i {
      width: 18px;
      height: 18px;
    }
    svg {
      width: 18px;
      height: 18px;
    }
  }

  .main-container {
    position: relative;
    height: 100vh;
    min-height: 100%;
    margin-left: $sideBarWidth;
    background: #f0f2f5;

    /* main-content 属性动画 */
    transition: margin-left 0.3s;

    .el-scrollbar__wrap {
      height: 100%;
      overflow: auto;
    }
  }

  .layout-header {
    position: fixed;
    top: 0;
    right: 0;
    z-index: 998;
    width: calc(100% - #{$sideBarWidth});

    /* layout-header 属性左上角动画 */
    transition: width 0.3s;
  }

  .main-hidden {
    margin-left: 0 !important;

    .layout-header {
      width: 100% !important;

      + .app-main {
        padding-top: 37px !important;
      }
    }
  }

  .sidebar-container {
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    z-index: 1001;
    width: $sideBarWidth !important;
    height: 100%;
    overflow: visible;
    font-size: 0;
    background: #fff;
    border-right: 1px solid rgb(5 5 5 / 6%);
    /* 展开动画 */
    transition: width 0.3s;

    .scrollbar-wrapper {
      overflow-x: hidden !important;
    }
    &.has-logo {
      .el-scrollbar.pc {
        /* logo: 48px、leftCollapse: 40px、leftCollapse-shadow: 4px */
        height: calc(100% - 92px);
      }

      /* logo: 48px */
      .el-scrollbar.mobile {
        height: calc(100% - 48px);
      }
    }

    &.no-logo {
      .el-scrollbar.pc {
        /* leftCollapse: 40px、leftCollapse-shadow: 4px */
        height: calc(100% - 44px);
      }

      .el-scrollbar.mobile {
        height: 100%;
      }
    }
    .el-menu {
      height: 100%;
      background-color: transparent !important;
      border: none;
    }

    .el-menu-item,
    .el-sub-menu__title {
      height: 50px;
      color: rgb(0 0 0 / 60%);
      background-color: transparent !important;

      &:hover {
        color: #000 !important;
      }

      div,
      span {
        height: 50px;
        line-height: 50px;
      }
    }

    .el-sub-menu__title {
      &:hover {
        background-color: transparent;
      }
    }

    .is-active > .el-sub-menu__title {
      color: #000000d9 !important;

      i {
        color: #000000d9 !important;
      }
    }

    .is-active {
      color: #000000d9 !important;
      transition: color 0.3s;
    }

    .el-menu-item.is-active > * {
      z-index: 1;
      color: #fff;
    }

    .el-menu-item.is-active::before {
      position: absolute;
      inset: 0 8px;
      margin: 4px 0;
      clear: both;
      content: "";
      background: var(--el-color-primary) !important;
      border-radius: 3px;
    }

    .el-menu .el-menu--inline .el-sub-menu__title,
    & .el-sub-menu .el-menu-item {
      min-width: $sideBarWidth !important;
      font-size: 14px;
      background-color: #fff !important;
    }
    /* 有子集的激活菜单左侧小竖条 */
    .el-menu--collapse .is-active.el-sub-menu > .el-sub-menu__title::before {
      position: absolute;
      top: 0;
      left: 0;
      width: 2px;
      height: 100%;
      clear: both;
      content: "";
      background-color: #4091f7;
      transition: all 0.3s ease-in-out;
      transform: translateY(0);
    }

    .el-menu--collapse .el-sub-menu > .el-sub-menu__title::before {
      position: absolute;
      top: 50%;
      display: block;
      width: 3px;
      height: 0;
      content: "";
      transform: translateY(-50%);
    }
  }

  /* vertical 菜单折叠 */
  .el-menu--vertical {
    .el-menu--popup {
      background-color: #fff !important;

      .el-menu-item {
        span {
          font-size: 14px;
        }
      }
    }

    & > .el-menu {
      i,
      svg {
        margin-right: 5px;
      }
    }

    .is-active > .el-sub-menu__title {
      color: #000000d9 !important;

      i {
        color: #000000d9 !important;
      }
    }

    /* 子菜单中还有子菜单 */
    .el-menu .el-sub-menu__title {
      min-width: $sideBarWidth !important;
      font-size: 14px;
      background-color: #fff !important;
    }

    .el-menu-item,
    .el-sub-menu__title {
      height: 50px;
      line-height: 50px;
      color: rgb(0 0 0 / 60%);
      background-color: #fff;

      &:hover {
        color: #000 !important;
      }
    }

    .is-active {
      color: #000000d9 !important;
      transition: color 0.3s;
    }

    .el-menu-item.is-active > * {
      z-index: 1;
      color: #fff;
    }

    .el-menu-item.is-active::before {
      position: absolute;
      inset: 0 8px;
      clear: both;
      content: "";
      background: var(--el-color-primary) !important;
      border-radius: 3px;
    }

    .el-menu-item,
    .el-sub-menu {
      .iconfont {
        font-size: 18px;
      }

      .el-menu-tooltip__trigger {
        width: 54px;
        padding: 0;
      }
    }
  }

  /* horizontal 菜单 */
  .el-menu--horizontal {
    & > .el-sub-menu .el-sub-menu__icon-arrow {
      position: static !important;
      margin-top: 0;
    }

    /* 无子菜单时激活 border-bottom */
    a > .is-active.submenu-title-noDropdown {
      border-bottom: 2px solid var(--el-menu-active-color);
    }

    .el-menu--popup {
      background-color: #fff !important;

      a > .is-active.submenu-title-noDropdown {
        border-bottom: none;
      }

      .el-menu-item {
        color: rgb(0 0 0 / 60%);
        background-color: #fff;

        span {
          font-size: 14px;
        }
      }

      .el-sub-menu__title {
        color: rgb(0 0 0 / 60%);
      }
    }

    /* 子菜单中还有子菜单 */
    .el-menu .el-sub-menu__title {
      min-width: $sideBarWidth !important;
      font-size: 14px;
      background-color: #fff !important;

      &:hover {
        color: #000 !important;
      }
    }

    .is-active > .el-sub-menu__title,
    .is-active.submenu-title-noDropdown {
      color: #000000d9 !important;

      i {
        color: #000000d9 !important;
      }
    }

    .nest-menu .el-sub-menu > .el-sub-menu__title,
    .el-menu-item {
      &:hover {
        color: #000 !important;
      }
    }

    .el-menu-item.is-active {
      color: #000000d9 !important;
      transition: color 0.3s;
    }

    .el-menu-item.is-active > * {
      z-index: 1;
      color: #fff;
    }

    .el-menu-item.is-active::before {
      position: absolute;
      inset: 0 5px;
      clear: both;
      content: "";
      background: var(--el-color-primary) !important;
      border-radius: 3px;
    }
  }

  .el-menu--collapse .el-menu .el-sub-menu {
    min-width: $sideBarWidth !important;
  }

  /* 手机端 */
  .mobile {
    .layout-header {
      width: 100% !important;
      transition: width 0.3s;
    }

    .main-container {
      margin-left: 0 !important;
    }

    .sidebar-container {
      width: $sideBarWidth;
      transition: transform 0.3s;
    }

    &.hideSidebar {
      .sidebar-container {
        pointer-events: none;
        transition-duration: 0.3s;
        transform: translate3d(-$sideBarWidth, 0, 0);
      }
    }
  }
}

body[layout="vertical"] {
  $sideBarWidth: 210px;
  @include merge-style($sideBarWidth);

  .el-menu--collapse {
    width: 54px;
  }

  .hideSidebar {
    .layout-header {
      width: calc(100% - 54px);
      transition: width 0.3s;
    }
    .sidebar-container {
      width: 54px !important;
      transition: width 0.3s;
    }

    .main-container {
      margin-left: 54px;
    }

    /* 菜单折叠 */
    .el-menu--collapse {
      .el-menu-item,
      .el-sub-menu {
        .el-menu-tooltip__trigger {
          justify-content: center;
        }
        span {
          display: none !important;
        }
      }
      .el-sub-menu {
        & > .el-sub-menu__title {
          justify-content: center;
          & > span {
            width: 100%;
            height: 100%;
            text-align: center;
            visibility: visible;
          }
        }
      }

      .el-sub-menu__title {
        padding: 0;
      }
    }
    .el-menu--vertical {
      .is-active {
        color: #fff !important;
      }
    }
    .sub-menu-icon {
      margin-right: 0;
    }
  }
}

body[layout="horizontal"] {
  $sideBarWidth: 0;
  @include merge-style($sideBarWidth);
}

body[layout="mix"] {
  $sideBarWidth: 210px;
  @include merge-style($sideBarWidth);
}
